import turtle
import random

# 设置窗口
screen = turtle.Screen()
screen.bgcolor("black")
screen.title("Merry Christmas")

# 创建一个画布
canvas = turtle.Turtle()
canvas.speed(0)  # 设置速度，0为最快

def draw_star(x, y, size):
    canvas.penup()
    canvas.color("white")
    canvas.goto(x, y)
    canvas.begin_fill()

    for _ in range(5):
        canvas.forward(size)
        canvas.right(144)

    canvas.end_fill()

def draw_circle(x, y, color, size):
    canvas.penup()
    canvas.color(color)
    canvas.goto(x, y - size)
    canvas.begin_fill()
    canvas.circle(size)
    canvas.end_fill()

def draw_rectangle(x, y, color, width, height):
    canvas.penup()
    canvas.color(color)
    canvas.goto(x - width / 2, y - height / 2)
    canvas.begin_fill()

    for _ in range(4):
        canvas.forward(width if _ % 2 == 0 else height)
        canvas.left(90)

    canvas.end_fill()

# 画星光
for _ in range(50):
    x = random.randint(-300, 300)
    y = random.randint(-150, 150)
    size = random.randint(1, 4)
    draw_star(x, y, size)

# 画圣诞树
canvas.color("green")
canvas.begin_fill()
canvas.goto(0, -150)
canvas.left(90)
canvas.forward(100)
canvas.right(90)
canvas.forward(40)
canvas.right(90)
canvas.forward(100)
canvas.end_fill()

# 画圣诞树上的小果子
for _ in range(10):
    x = random.randint(-30, 30)
    y = random.randint(60, 120)
    color = random.choice(["red", "orange"])
    size = random.randint(5, 15)
    draw_circle(x, y, color, size)

# 画动态飘带
for _ in range(12):
    x = random.randint(-30, 30)
    y = random.randint(-150, 50)
    color = random.choice(["red", "green", "gold"])
    width = random.randint(5, 10)
    height = random.randint(40, 80)
    draw_rectangle(x, y, color, width, height)

# 画礼物盒
draw_rectangle(0, -150, "red", 40, 40)
draw_rectangle(20, -150, "gold", 10, 20)
draw_rectangle(-20, -150, "gold", 10, 20)

# 隐藏画笔
canvas.hideturtle()

# 显示窗口
turtle.done()
